<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
</head>

<body>
<div id="o"></div>
<script src="c.js"></script>

<script>

  var outEl = document.getElementById('o')
  var res = []
  var err = 0
  var n = 3

  fetch('a.js', function() { done('a') })
  fetch('b.js', function() { done('b') })
  fetch('c.js', function() { done('c') })


  function fetch(src, callback) {
    var node = document.createElement('script')
    addOnload(node, callback)
    node.src = src
    outEl.appendChild(node)
  }

  function addOnload(node, callback) {
    if (node.addEventListener) {
      node.addEventListener('load', callback, false);
      node.addEventListener('error', function() {
        err = 2
        callback()
      }, false)
    }
    else { // for IE6-8
      node.onreadystatechange = function() {
        var rs = node.readyState
        if (rs === 'loaded' || rs === 'complete') {
          node.onreadystatechange = null
          callback()
        }
      }
    }
  }


  function done(c) {
    res.push(c)
    if (--n === 0) complete()
  }

  function complete() {
    var s = err + res.join('')

    if (self.top != self) {
      sendResult(s)
    }
    else {
      printResult(s)
    }
  }

  window.onerror = function() {
    err = 1
    complete()
  }

  function sendResult(s) {
    s += location.href.charAt(location.href.length - 1) // rip UA
    var img = new Image()
    img.onload = function() {
    }
    img.src = 'http://stats.tudou.com/e/tmp/a10/?v=1&s=16015||||||' + s + '|||'
  }

  function printResult(txt) {
    var d = document.createElement('div')
    d.innerHTML = txt
    outEl.appendChild(d)
  }

</script>
</body>
</html>